package com.aaa.boot.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

/**
 * @author 单简i
 * 创建时间:2025/3/6 16:18
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class AjaxResult implements Serializable {
    private Integer code;
    private String  msg;
    private Object  data;

    public AjaxResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static AjaxResult success(){return new AjaxResult(200,"操作成功",null);}
    public static AjaxResult success(String msg){return new AjaxResult(200,msg,null);}
    public static AjaxResult success(Object data){return new AjaxResult(200,"操作成功",data);}
    public static AjaxResult success(int code,String msg){return new AjaxResult(code,msg,null);}
    public static AjaxResult success(String msg,Object data){return new AjaxResult(200,msg,data);}
    public static AjaxResult success(int code,String msg,Object data){return new AjaxResult(code,msg,data);}
    public static AjaxResult error(){
        return new AjaxResult(400,"对不起操作失败",null);
    }
    public static AjaxResult error(String msg){
        return new AjaxResult(400,msg,null);
    }
    public static AjaxResult error(int code,String msg){
        return new AjaxResult(400,msg,null);
    }
}
